//
//  ZFBindedCardViewController.m
//  HappilyLoan
//
//  Created by zainishenbian on 2017/3/29.
//  Copyright © 2017年 zongqingxiangqian. All rights reserved.
//

#import "ZFBindedCardViewController.h"
#import "ZFMyBindCardViewController.h"//重新绑定银行卡
#import "ZLCBankCardInfoModel.h"
#import "PublicClass.h"
#import "ZFHeader.h"

@interface ZFBindedCardViewController ()
@property (nonatomic, strong)NSMutableArray *bankCardInfoList;
@property (nonatomic,strong) AnimatingView *anima;
@property (nonatomic,strong) AlertBoxView *alertV;
@end

@implementation ZFBindedCardViewController

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [MobClick beginLogPageView:@"bindedCard"];
    self.navigationController.navigationBarHidden = NO;
    [_anima startTheAnimation];
    _BindeCardButton.hidden = YES;
    [ZFMyInfoHttpRequest requestBankCardInfosucessBlock:^(NSDictionary *dict) {
        [_anima stopTheAnimation];

        if (dict[@"data"] == [NSNull null]) {
            
        }
        else{
            _bankCardInfoList = dict[@"data"];
            
            [self performSelector:@selector(loadSiteSearchData) withObject:nil afterDelay:1.0];
        }
    } failureBlock:^(NSInteger failSign) {
        
        [_alertV appearAndDisappearAlertWithString:@"网络连接失败"];
    }];

}
- (void)viewDidDisappear:(BOOL)animated{
    [_anima stopTheAnimation];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"绑定银行卡";
    
    _alertV = [[AlertBoxView alloc] init];
    [self.view addSubview:_alertV];
    
    self.bankCardInfoList = [NSMutableArray array];
    
    self.anima = [[AnimatingView alloc] initWithFrame:self.view.bounds];

     [_BindeCardButton setShadowWidth:2 shadowHeight:2 shadowColor:Main_Color1 radius:10];
    
}

-(void)loadSiteSearchData{
    
    [_anima stopTheAnimation];
    NSDictionary *dic = (NSDictionary *)self.bankCardInfoList;
    _BankNameLabel.text =  [NSString stringWithFormat:@"%@",dic[@"bank_name"] ];
    _BankPhoneLabel.text =  [NSString stringWithFormat:@"%@",dic[@"bank_phone"]];
    _BankNumberLabel.text =  [NSString stringWithFormat:@"%@",dic[@"bank_no"]];
}
#pragma mark ———— button的点击事件
//重新绑定银行卡
- (IBAction)OnceBindCard:(id)sender {
    
    ZFMyBindCardViewController *bindVC = [ZFMyBindCardViewController new];
    bindVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:bindVC animated:YES];
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [MobClick beginLogPageView:@"bindedCard"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
